﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;

namespace Sisocana.Services
{
    [ServiceContract]
    public interface ISearchPeople
    {
        [OperationContract]
        List<Person> AdvancedSearchPerson(SearchParameters sp);

        [OperationContract]
        List<Person> keywordSearchPerson(int idSitio,string keyword);

        [OperationContract]
        PersonDetails getPersonDetails(int idSitio, int id);

        //Devuelve 0 cuando se agrega correctamente
        [OperationContract]
        int addReport(Report r);
    }

    [DataContract(Namespace = "http://schemas.datacontract.org/2004/07/WCFServiceSearchPerson.DataContracts")]
    public class SearchParameters
    {
        //si viene vacio se busca en todos los sitios de la aplicacion
        [DataMember]
        public int siteId;
        [DataMember]
        public string firstName;
        [DataMember]
        public string lastName;
        [DataMember]
        public string phone;

        //permiten buscar personas desaparecidas en ese rango de fechas
        [DataMember]
        public Nullable<DateTime> missingDateFrom;
        [DataMember]
        public Nullable<DateTime> missingDateTo;
    }

    [DataContract(Namespace = "http://schemas.datacontract.org/2004/07/WCFServiceSearchPerson.DataContracts")]
    public class Person
    {
        [DataMember(IsRequired = true)]
        public int siteId;
        [DataMember(IsRequired = true)]
        public int id;
        [DataMember]
        public string firstName;
        [DataMember]
        public string lastName;
        [DataMember]
        public string phone; 
        [DataMember]
        public DateTime missingDate;
    }

    [DataContract(Namespace = "http://schemas.datacontract.org/2004/07/WCFServiceSearchPerson.DataContracts")]
    public class PersonDetails
    {
        [DataMember(IsRequired = true)]
        public int siteId;
        [DataMember(IsRequired = true)]
        public int id;
        [DataMember]
        public string firstName;
        [DataMember]
        public string lastName;
        [DataMember]
        public string phone;
        [DataMember]
        public DateTime missingDate;
        [DataMember]
        public string description;
        [DataMember]
        public int age;
        //<genre value="M"> Male </option>
        //<genre value="F"> Female </option>
        [DataMember]
        public string genre;
        [DataMember]
        public DataImage photo;
        [DataMember]
        public Address address;
        [DataMember]
        public List<Report> reports;
    }


    [DataContract(Namespace = "http://schemas.datacontract.org/2004/07/WCFServiceSearchPerson.DataContracts")]
    public class DataImage
    {
        [DataMember]
        public string imgName;
        [DataMember]
        public string imgExt;
        [DataMember]
        public byte[] imgByte;
    }

    [DataContract(Namespace = "http://schemas.datacontract.org/2004/07/WCFServiceSearchPerson.DataContracts")]
    public class Address
    {
        [DataMember]
        public string coordX;
        [DataMember]
        public string coordY;
        [DataMember]
        public string country;
        [DataMember]
        public string state;
        [DataMember]
        public string city;
        [DataMember]
        public string address;
        [DataMember]
        public string cp;
    }

    [DataContract(Namespace = "http://schemas.datacontract.org/2004/07/WCFServiceSearchPerson.DataContracts")]
    public class Report
    {
        [DataMember(IsRequired = true)]
        public int siteId;

        [DataMember(IsRequired = true)]
        public int personId;

        //informacion del que reporta
        [DataMember]
        public string firstName;
        [DataMember]
        public string lastName;
        [DataMember]
        public string email;
        [DataMember]
        public string phone;
        [DataMember]
        public DateTime date;

        //<status value="U"> Unspecified </option>
        //<status value="I"> I am seeking information </option>
        //<status value="M"> The person is missing </option>
        //<status value="A"> The person is alive </option>
        //<status value="D"> The person is dead </option>
        [DataMember]
        public string status;
        [DataMember]
        public string message;
        [DataMember]
        public string CoordX;
        [DataMember]
        public string CoordY;

    }
}
